home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
tlx_sq21.zip
/
GETNAME.SLT
< prev
next >
Wrap
Text File
|
1992-03-20
|
12KB
|
336 lines
//-----------------------------------------------------------
// GETNAME.SL? Get variables from the NAME.DAT file.
//-----------------------------------------------------------
// If you have suggestions for improving this script, please suggest
// improvements to me via old-fashioned snail-mail to:
// Author: Inge Vabekk
// Hamangskogen 108
// N-1300 SANDVIKA
// NORWAY
// tel. (472) 546 396
str namefile [12]= "NAME.DAT" // File containing name etc.
,fonedir [12]= "TELIX.FON" // Default phone directory
,global []= "GLOBAL" // Name of global script
,logon []= "LOGON" // Logon script.
,passw []= "PASSWORD" // Password script.
,escape []= "ESCAPE" // Name of ESCAPE script
,cputl []= "PUTLINE" // Script to output one line.
,join []= "JOINCONF" // Join Conference script.
,updownf []= "UPDOWNF" // Script to send/receive file.
,display []= "DISPLAY" // Display script.
,logoff []= "LOGOFF" // Script for auto logoff toggle
,prompt []= "PROMPT" // Command prompt.
,cprot []= "CPROT" // Current protocol
,maxup []= "MAXUP" // Max no. of upload files.
,maxdn []= "MAXDN" // Max no. of download files.
,graph []= "GRAPH" // Graphics Y/N.
,Aexit []= "EXIT" // Auto Exit Y/N
,name []= "NAME" // Global: User name.
,mdir []= "MDIR" // Global: Mail directory.
,ssl []= "SSL" // Status line.
,errormess[80] // For error message.
,inputline[160] // For reading NAME.DAT file.
,varname [6]
;
int file // File handle
,namelen=6 // Length of names
,stringlen=80 // Max. length of variables
;
//-----------------------------------------------------------
// Script starts here.
//-----------------------------------------------------------
main (int first)
{
int c, i, l;
// Check that important scripts are loaded.
if (first == 1)
{ i = load_scripts();
return (i);
}
//prints ("T²: Just a moment please....");
write (prompt,"Command"); // Set some defaults.
write (cprot,"Z"); // Protocol: Zmodem.
write (maxup,"10"); // Max no. for upload.
write (maxdn,"10"); // Max no. for download.
write (graph,"NO"); // Graphics
write (Aexit,"NO"); // Auto Exit.
write (prompt," Command"); // Set default command prompt.
if ((file=fopen(namefile,"r"))<=0)
{ errormess = namefile;
strcat (errormess," not found!");
status_wind (errormess,20); // Show error message.
return (-1);
}
// Read the NAME.DAT file.
while (fgets(inputline,160,file)>0) // Get input line.
codeset (); // Find and set the code.
fclose (file); // Close the file
read ("Graph",inputline); // Graphics?
setchr(inputline,1,0); // Set graphics, Y or N.
strupper(inputline);
if (inputline != "Y") inputline = "N";
write ("Graph",inputline);
if (read ("Fdir",errormess) < 0) // phone directory,
write ("Fdir",fonedir);
read (mdir,errormess); // Mail directory
for (l=strlen(errormess)-1; l>0; --l)
{ if (subchr(errormess,l) !='\')
break;
setchr (errormess,l,0); // Delete trailing slash.
}
exec ("CRDIR",errormess); // Create directory.
strcat (errormess,"\"); // Add slash again.
write (mdir,errormess); // Set mail directory
return (0); // and return.
}
//-----------------------------------------------------------
// Routine to decode one line from the input file.
//-----------------------------------------------------------
codeset()
{
int i, k, l, c;
if ((k=strchr(inputline,0,'{')) >= 0) // Comment in this line?
{ substr (inputline,k+1,80,errormess); // Move rest to temp.
setchr (inputline,k,0); // Truncate here.
l=strchr(errormess,0,'}'); // End of comment?
if (l<0)
setchr (errormess,0,0); // Not found. All is comment.
else
substr (errormess,l+1,80,errormess); // Delete comment.
strcat (inputline,errormess); // Add the rest.
}
k = strchr(inputline,0,'='); // Find first equal sign.
if (k < 0) return(0); // Not found!
varname = inputline; // Copy to varname.
if (k<=namelen)
setchr (varname,k,0); // Delete all from '='.
strcat (varname," "); // Fill with spaces.
// Isolate variable. Find first non-space after colon.
while ((c=subchr(inputline,++k))>0)
if (c > ' ') break; // Non-space found.
if (c < ' ') return(0); // Invalid input.
for (l = strlen(inputline)-1; l>=k; --l)
if (subchr(inputline,l) > ' ') // Remove trailing spaces.
break;
setchr(inputline,++l,0); // Insert terminator.
// Move string down to start at 0.
substr (inputline,k,stringlen,inputline);
c = subchr(varname,0); // Check for key names.
if (toupper(c) =='F')
{ setchr (varname,0,' ');
i = stoi (varname);
setchr (varname,0,'F');
if (i > 0 && i < 13)
{ if (strcmpi (inputline,"@name") == 0) // Replace "@name" by name.
{ if (read (name,inputline) < 0)
status_wind ("T²: Name is not defined before the user name key!",20);
}
if (i == 1) // F1 key.
keyset (0x3b00,0,inputline);
else if (i == 2) // F2 key.
keyset (0x3c00,0,inputline);
else if (i == 3) // F3 key.
keyset (0x3d00,0,inputline);
else if (i == 4) // F4 key.
keyset (0x3e00,0,inputline);
else if (i == 5) // F5 key.
keyset (0x3f00,0,inputline);
else if (i == 6) // F6 key.
keyset (0x4000,0,inputline);
else if (i == 7) // F7 key.
keyset (0x4100,0,inputline);
else if (i == 8) // F8 key.
keyset (0x4200,0,inputline);
else if (i == 9) // F9 key.
keyset (0x4300,0,inputline);
else if (i == 10) // F10 key.
keyset (0x4400,0,inputline);
else if (i == 11) // F11 key.
keyset (0x8500,0,inputline);
else if (i == 12) // F12 key.
keyset (0x8600,0,inputline);
return (0);
}
}
write (varname,inputline); // Define this global.
return(0);
}
//-----------------------------------------------------------
// Load scripts.
//-----------------------------------------------------------
load_scripts()
{
if (!is_loaded(global)) // Load "Global" script
{ load_scr (global); // permanently.
if (!is_loaded(global)) // Loaded?
{ nosuccess(global); // No success:
return (-1);
}
}
if (!is_loaded (ssl)) // Load "SSL" script
{ load_scr (ssl); // permanently.
if (!is_loaded(ssl)) // Loaded?
{ nosuccess(ssl); // No success:
return (-1);
}
}
if (!is_loaded (escape)) // Load ESCAPE script
{ load_scr (escape); // permanently.
if (!is_loaded(escape)) // Loaded?
{ nosuccess(escape); // No success:
return (-1);
}
}
if (!is_loaded (cputl)) // Load PUTLINE script